// ClassStudentController.java
package com.example.teacherservice.controller;

import com.example.teacherservice.entity.StuClass;
import com.example.teacherservice.service.ClassStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/classes/{classId}/students")
public class ClassStudentController {

    @Autowired
    private ClassStudentService classStudentService;

    @PostMapping("/{studentId}")
    public void addStudentToClass(
            @PathVariable Long classId,
            @PathVariable Long studentId) {
        classStudentService.addStudentToClass(classId, studentId);
    }

    @DeleteMapping("/{studentId}")
    public void removeStudentFromClass(
            @PathVariable Long classId,
            @PathVariable Long studentId) {
        classStudentService.removeStudentFromClass(classId, studentId);
    }

    @GetMapping
    public List<StuClass> getClassStudents(@PathVariable Long classId) {
        return classStudentService.getClassStudents(classId);
    }
}